<?php
/* [$WindsForce] (C)Hunzhiwange.COM Since 2014.07.28.
   家居商家设计师控制器($$)*/

!defined('Q_PATH') && exit;

class JiajudesignerController extends AController{

	public function filter_(&$arrMap){
		$arrMap['A.jiajudesigner_position']=array('like',"%".Q::G('jiajudesigner_position')."%");
		$arrMap['A.jiajudesigner_style']=array('like',"%".Q::G('jiajudesigner_style')."%");
		$arrMap['A.jiajudesigner_telephone']=array('like',"%".Q::G('jiajudesigner_telephone')."%");
		$arrMap['A.jiajudesigner_qq']=array('like',"%".Q::G('jiajudesigner_qq')."%");
		$arrMap['A.jiajudesigner_school']=array('like',"%".Q::G('jiajudesigner_school')."%");
		$arrMap['A.jiajudesigner_name']=array('like',"%".Q::G('jiajudesigner_name')."%");

		// 添加时间
		$this->getTime_('A.create_dateline',$arrMap);

		$nJiajudesignerType=Q::G('jiajudesigner_type');
		if($nJiajudesignerType!==null && $nJiajudesignerType!=''){
			$arrMap['A.jiajudesigner_type']=$nJiajudesignerType;
		}

		// 待审
		$this->getAudit_('A.jiajudesigner_status',$arrMap);
	}

	public function index($sModel=null,$bDisplay=true){
		parent::index('jiajudesigner',false);
		$this->display(Admin_Extend::template('jiaju','jiajudesigner/index'));
	}

	protected function sqljoin_(){
		return "->join('".Q::C('DB_PREFIX')."jiajucompany AS C','C.jiajucompany_id,C.jiajucompany_fullname,C.jiajucompany_isfvip,C.jiajucompany_domain','A.jiajucompany_id=C.jiajucompany_id')";
	}

	public function check_user(){
		$nUserid=trim(Q::G('user_id'));
		$nId=intval(Q::G('value'));

		if(!$nUserid){
			exit('true');
		}

		// 判断是否存在该帐号
		$oUser=UserModel::F('user_id=? AND user_status=1',$nUserid)->setColumns('user_id')->getOne();
		if(empty($oUser['user_id'])){
			exit('false');
		}

		// 查询条件
		$arrWhere=array();
		$arrWhere['user_id']=$nUserid;
		if($nId){
			$arrWhere['jiajudesigner_id']=array('neq',$nId);
		}

		$oJiajudesigner=JiajudesignerModel::F()->where($arrWhere)->setColumns('jiajudesigner_id')->getOne();
		if(empty($oJiajudesigner['jiajudesigner_id'])){
			exit('true');
		}else{
			exit('false');
		}
	}

	public function add(){
		$this->display(Admin_Extend::template('jiaju','jiajudesigner/add'));
	}

	public function edit($sMode=null,$nId=null,$bDidplay=true){
		$nId=intval(Q::G('value','G'));
		parent::edit('jiajudesigner',$nId,false);
		$this->display(Admin_Extend::template('jiaju','jiajudesigner/add'));
	}

	public function insert($sModel=null,$nId=null){
		$nId=Q::G('value');
		parent::insert('jiajudesigner',$nId);
	}

	public function update($sModel=null,$nId=null){
		$nId=Q::G('value');
		parent::update('jiajudesigner',$nId);
	}

	public function forbid($sModel=null,$sId=null,$bApp=false){
		$nId=intval(Q::G('value','G'));
		parent::forbid('jiajudesigner',$nId,true);
	}

	public function resume($sModel=null,$sId=null,$bApp=false){
		$nId=intval(Q::G('value','G'));
		parent::resume('jiajudesigner',$nId,true);
	}

	public function clear_recycle($sModel=null,$sField='status'){
		parent::clear_recycle('jiajudesigner',$sField);
	}

	public function foreverdelete_deep($sModel=null,$sId=null){
		$sId=Q::G('value');
		parent::foreverdelete_deep('jiajudesigner',$sId);
	}

	public function foreverdelete($sModel=null,$sId=null,$bApp=false){
		$sId=Q::G('value');
		parent::foreverdelete('jiajudesigner',$sId,true);
	}

	public function view_preview($sMode=null,$nId=null,$bDidplay=true){
		$nId=intval(Q::G('value','G'));
		parent::view_preview('jiajudesigner',$nId,false);
		$this->display(Admin_Extend::template('jiaju','jiajudesigner/viewpreview'));
	}

	public function save_preview($sMode=null,$nId=null){
		$nId=intval(Q::G('value','G'));
		parent::save_preview('jiajudesigner',$nId);
	}

	public function save_previewstatus($sMode=null,$nId=null){
		$nId=intval(Q::G('value','G'));
		parent::save_previewstatus('jiajudesigner',$nId);
	}

}
